﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace SPVisualDev
{
    public partial class DialogIncludedAssemblies : Form
    {
        public DialogIncludedAssemblies()
        {
            InitializeComponent();
        }

        public struct IncludeAssemblyStruct
        {
            public string Name;
            public bool Included;

            public IncludeAssemblyStruct(string Name, bool Included)
            {
                this.Name = Name;
                this.Included = Included;
            }
        }

        public List<IncludeAssemblyStruct> Assemblies
        {
            get
            {
                List<IncludeAssemblyStruct> ret = new List<IncludeAssemblyStruct>();
                for (int i = 0; i < lstIncludedAssemblies.Items.Count; i++)
                {
                    if (lstIncludedAssemblies.CheckedIndices.IndexOf(i) != -1)
                        ret.Add(new IncludeAssemblyStruct(lstIncludedAssemblies.Items[i] as string, true));
                    else
                        ret.Add(new IncludeAssemblyStruct(lstIncludedAssemblies.Items[i] as string, false));
                }

                return ret;
            }
            set
            {
                lstIncludedAssemblies.Items.Clear();
                if (value != null)
                {
                    foreach (IncludeAssemblyStruct asm in value)
                        lstIncludedAssemblies.Items.Add(asm.Name, asm.Included);
                }
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Hide();
        }
    }
}
